package marchsoft.modules.four.h5.service.Impl;

import marchsoft.modules.four.common.entity.SafeCase;
import marchsoft.modules.four.common.entity.SafeType;
import marchsoft.modules.four.common.entity.Slideshow;
import marchsoft.modules.four.common.entity.StudyData;
import marchsoft.modules.four.h5.mapper.HomeMapper;
import marchsoft.modules.four.h5.service.HomeService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 首页 service 层 接口 实现类
 */
@Service
public class HomeServiceImpl implements HomeService {
    //注入mapper
    private final HomeMapper homeMapper;

    public HomeServiceImpl(HomeMapper homeMapper) {
        this.homeMapper = homeMapper;
    }

    @Override
    public List<StudyData> getEStudyDataFront1(long safeTypeId){
        return homeMapper.selectEstudyByid(safeTypeId);
}

    @Override//查询所有轮播图信息
    public List<Slideshow> getESlideshowAll() {
        return homeMapper.SelectESlideshowAll();
    }

    @Override//根据id查询某一个轮播图对应的文章详细信息
    public List<StudyData> getEStudyDataFront(long parseLong) {
        return homeMapper.SelectEStudyDataFrontById(parseLong);
    }

    @Override//根据id点赞控制
    public boolean getEStudyDataFrontLike(long parseLong) {
        return homeMapper.updateEStudyDataFrontLike(parseLong) == 1;
    }

    @Override//取消点赞
    public boolean getEStudyDataFrontUnLike(long id) {
        return homeMapper.updateEStudyDataFrontUnLike(id) == 1;
    }

    @Override//踩
    public boolean getEStudyDataFrontDislike(long id) {
        return homeMapper.updateEStudyDataFrontDislike(id) == 1;
    }

    @Override//取消踩
    public boolean getEStudyDataFrontUnDislike(long id) {
        return homeMapper.updateEStudyDataFrontUnDislike(id) == 1;
    }

    @Override//获取分类信息
    public List<SafeType> getESafeTypeFrontAll() {
        return homeMapper.selectESafeTypeFrontAll();
    }

    @Override//今日推荐
    public List<StudyData> getEStudyDataFrontDaily(int little) {
        return homeMapper.selectEStudyDataFrontDaily(little);
    }

    @Override//经典案例
    public List<SafeCase> getESafeCaseFrontAll(int i) {
        return homeMapper.selectESafeCaseFrontAll(i);
    }

    @Override//看了看
    public Object getEStudyDataFrontRead(long id, int count) {
        return homeMapper.updateEStudyDataFrontRead(id, count) == 1 ? "成功" : "失败";
    }

}
